The present invention relates to a processor for processing programs.
Considering a computer or processor for processing programs, the stack is one of the important concepts. The stack means, as mentioned in "16-Bit Microcomputer and Programming Basics" (published by CQ, page 212), in a device for reading out the data in the reverse sequence of it being written in.
A conceptual drawing of a conventional processor is shown in FIG. 1. In a processor 100 shown in FIG. 1, generally, one of the registers in the processor 100 is used as a stackpointer for stack access, and one of the external memories 118 is assigned as a stack region 120 to realize a stack. The push action and pop action which are two basic actions in this stack are briefly explained below. Relating first to the push action, the initial state shown in FIG. 2(a) is supposed. At this time, the memory in the shaded area is already used. To begin with, one is substracted from the address of the stackpointer. As a result, the address of the stackpointer indicates one address before as shown in FIG. 2(b). Next, by accessing the external memory 118 from this address, the data is written in as shown in FIG. 2(c).
The pop action is then explained. The initial state is supposed as shown in FIG. 3(a). First, as shown in FIG. 3(b), the external memory 118 is accessed by the address of the stackpointer, and the date is read out. Furthermore, as shown in FIG. 3(c), one is added to the adress of the stackpointer.
The satck is mainly used in a subroutine in FORTRAN or other computer language, and at the time of subroutine call, the push action is effected in order to save the data into the stack, and when returning from the subroutine, the pop action is effected to restore the data. The action in this case is described in further detail. When the subroutine is called in the main program of the program in FORTRAN or the like, the push action is effected in order to keep the return address of the program when returning from the subroutine. First of all, by the address of the stack-pointer which is one of the registers 108 in an execution unit 106, the address of the external memory 118 is specified by using an address bus. The address of an instruction pointer 110 at a control unit 104 is written into a stack region 120 of the external memory 118 through an internal bus 112 and data bus 114. The address of the written instruction pointer is read out from the external memory 118 by the pop action when returning from the subroutine and is used in order to continue the main program. In the conventional processor 100 as shown in FIG. 1, while accessing to the stack region 120 of the external memory 118, the next instruction to be received by an instruction decoding part 120 of the processor cannot be taken in. In the above explanation, the data to be saved in the external stack region 120 is only the address of the returning destination when returning from the subroutine, but generally the data of the register in the processor 100 is also saved. In this case, the operation for taking in the next instruction is further delayed. Therefore, in the processor 100 designed to take in the data and instruction from a same data bus, when saving the data at the time of subroutine call or resetting at the time of returning, the external data bus 114 of the processor 100 is more crowded. Generally, since the cycle time for accessing the external memory 118 is greater than the machine cycle time of the processor 100, the speed of the processor 100 is lowered.
Besides, in the structure of installing memory 10 and stackpointer only as a stack part 122 inside the processor as shown in FIG. 4 in order to avoid crowdedness of the external data bus 114, the user of the processor must be always conscious so as not to use up the memory 10 completely. That is, as shown in FIG. 5(a), when the subroutine call is repeated a number of times, a certain number of words of the memory 10 in the processor 100 are used. If the capacity of the memory 10 is 32 words, when 32 words of data are written in the memory 10, no more data can be written into the memory 10 as shown in FIG. 5(b). In this state, if data is written into the memory 10 by mistake, the data to be kept is broken as shown in FIG. 5(c). In FIGS. 5(a)-5(c), the shaded areas are areas of the memory being used and the unshaded areas are areas not being used.